home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Copyright (C) 1992 Ronin Consulting, Inc.
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; version 1.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- #import "Defaults.h"
- #import <appkit/Application.h>
-
- static id theOnlyOne = nil;
- static NXDefaultsVector noDefs = {{NULL}};
-
-
-
- @implementation Defaults
-
- + new
- {
- if(!theOnlyOne)
- {
- theOnlyOne = self = [super new];
- appName = [NXApp appName];
- registered = NO;
- }
- else
- self = theOnlyOne;
-
- return self;
- }
-
-
- - regDefaults:(NXDefaultsVector) defaultsVector
- {
- NXRegisterDefaults(appName, defaultsVector);
- registered = YES;
- return self;
- }
-
-
- - (const char *)get: (char *) aDefault
- {
- if(!registered)
- [self regDefaults: noDefs];
-
- return NXGetDefaultValue(appName, aDefault);
- }
-
- - set: (char *) aDefault to: (char *)aValue
- {
- if(!registered)
- [self regDefaults: noDefs];
-
- NXSetDefault(appName, aDefault, aValue);
- return self;
- }
-
- - (const char *) readDB: (char *) aDefault
- {
- if(!registered)
- [self regDefaults: noDefs];
-
- return NXReadDefault(appName, aDefault);
- }
-
- - writeDB: (char *) aDefault as: (char *)aValue
- {
- if(!registered)
- [self regDefaults: noDefs];
-
- NXWriteDefault(appName, aDefault, aValue);
- return self;
- }
-
-
- - remove: (char *) aDefault
- {
- if(!registered)
- [self regDefaults: noDefs];
-
- NXRemoveDefault(appName, aDefault);
- return self;
- }
-
- - update: (char *) aDefault
- {
- if(!registered)
- [self regDefaults: noDefs];
-
- NXUpdateDefault(appName, aDefault);
- return self;
- }
-
- - update
- {
- if(!registered)
- [self regDefaults: noDefs];
-
- NXUpdateDefaults();
- return self;
- }
-
-
- @end
-
-
-